<template>
	<view>
		<view class="">
			<view class="searchBox">
				<uni-search-bar @clear="clearSearch" radius="8" v-model="searchInput" :placeholder="placeholder"
					class="searchInput" cancelButton="none" />
				<text style="margin-right: 50rpx;" @click="search">{{ $t('common.Search') }}</text>
			</view>
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		name: "search",
		props: {},
		
		data() {
			return {
				searchInput: ''
			};
		},
		computed: {
			placeholder() {
				return this.$t('common.Keyword');
			},
		},
		methods: {
			search() {
				if (!this.searchInput) {
					uni.showToast({
						icon: 'none',
						title: '请输入关键词搜索'
					})
					return
				}
				this.$emit('search', this.searchInput)
			},
			clearSearch() {
				this.searchInput = ''
				this.$emit('clearSearch')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.searchBox {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.searchInput {
		width: 644rpx;
	}
</style>